			
	/* SVN FILE: $Id: user.js 8 2011-03-13 08:32:38Z michele.andreoletti@gmail.com $ */
	
	/**
	 * Project Name : arcadia
	 *
	 * @author $Author: michele.andreoletti@gmail.com $
	 * @version $Revision: 8 $
	 * @lastrevision $Date: 2011-03-13 08:32:38 +0000 (Sun, 13 Mar 2011) $
	 * @filesource $URL: http://arcadia.googlecode.com/svn/trunk/sysop/include/user.js $
	 */

	function fnHighLight (oObj) {
		oObj.addClass('ui-state-highlight');
		setTimeout(function() {
			oObj.removeClass('ui-state-highlight');
		}, 1250);
	}
		

	function fnRedirectTo (sScript) {
		var aAddr = $(location).attr('href').split("/");
		var sHref = "";
		$.each(aAddr, function(n, sVal) {
			if (n != aAddr.length-1) {
				if (sHref != '') {
					sHref = sHref + "/" + sVal;
				} else {
					sHref = sVal;
				}
			}
		});
		$(location).attr('href', sHref + "/" + sScript);
	}
		
	function updateTips (sText) {
		oTips.text(sText);
		fnHighLight (oTips);
	}
	
	function checkUsername (oObj) {
		bUnique = true;
		$('.unique').each(function() {
			if ($(this).text()==oObj.val()) {
				oObj.addClass('ui-state-error');
				updateTips("Username già in uso.");
				bUnique = false;
			}
		});
		return bUnique;
	};
	
	function checkCompare (oP1, oP2) {
		if ( oP1.val() != oP2.val() ) {
			oP2.addClass('ui-state-error');
			updateTips("La conferma della password inserita non coincide con la nuova password.");
			return false;
		} else {
			return true;
		}
	}
	
	function checkLength (o, n, min, max) {
		if ( o.val().length > max || o.val().length < min ) {
			o.addClass('ui-state-error');
			updateTips("Il campo " + n + " deve avere una lunghezza compresa tra "+min+" e "+max+" caratteri.");
			return false;
		} else {
			return true;
		}
	}
			
	function checkRegexp (o, regexp, n) {
		if ( !( regexp.test( o.val() ) ) ) {
			o.addClass('ui-state-error');
			updateTips(n);
			return false;
		} else {
			return true;
		}
	}